package com.example.schoolexam2.utils;


import com.example.schoolexam2.entity.EmployeeTemporaryBean;
import com.example.schoolexam2.entity.StudentTemporaryBean;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.Row;

public class InformationToolClass {
    public static StudentTemporaryBean Studentconversion(Row row) throws Exception {

        StudentTemporaryBean studentTemporaryBean = new StudentTemporaryBean();
        studentTemporaryBean.setStudentId(getCellValue(row,0));
        studentTemporaryBean.setName(getCellValue(row,1));
        studentTemporaryBean.setSex(getCellValue(row,2));
        studentTemporaryBean.setGrade(getCellValue(row,3));
        studentTemporaryBean.setId_Number(getCellValue(row,4));
        studentTemporaryBean.setYear(getCellValue(row,5));
        return studentTemporaryBean;
    }

    public static String getCellValue(Row row, int cell) {
        Cell cell1 = row.getCell(cell);
        cell1.setCellType(CellType.STRING);
        return cell1.getStringCellValue();
    }

    public static EmployeeTemporaryBean Employeeconversion(Row row) {
        EmployeeTemporaryBean employeeTemporaryBean = new EmployeeTemporaryBean();
        employeeTemporaryBean.setEmployeeId(getCellValue(row,0));
        employeeTemporaryBean.setEmployeeName(getCellValue(row,1));
        employeeTemporaryBean.setSex(getCellValue(row,2));
        employeeTemporaryBean.setIdNumber(getCellValue(row,3));
        return employeeTemporaryBean;
    }

}
